import React, { createRef, forwardRef, PureComponent } from 'react';

const Home = forwardRef(function(props, ref) {
  return (
    <div>
      <h2 ref={ref}>Home</h2>
      <button>按钮</button>
    </div>
  )
})

class App extends PureComponent {
  constructor(props) {
    super(props)
    this.homeTitleRef = createRef()
  }
  render() {
    return (
      <div>
        <Home ref={this.homeTitleRef}/>
        <button onClick={e=>this.printInfo()}>打印ref</button>
      </div>
    )
  }
  printInfo() {
    console.log(this.homeTitleRef.current)
  }
}


export default App;